package reflectx

type IRefObject interface {
	// RefType 结构的类名
	RefType() string
}

type IRefType interface {
	// RefType 结构的类名
	RefType() string
	// RefNew 生成结构
	RefNew() IRefObject
}

type IRefField interface {
	IRefType
	// RefHas 是否包含字段
	RefHas(field string) bool
	// RefGet 获取field的值
	RefGet(obj IRefObject, field string) (val interface{}, isNil bool)
	// RefSet 设置field的值
	RefSet(obj IRefObject, field string, val interface{})
}

type IRefMap interface {
	IRefField
	RefMapGet(obj IRefObject, field string, key string) (val interface{}, isNil bool)
	RefMapSet(obj IRefObject, field string, key string, val interface{})
	RefMapKeys(obj IRefObject, field string) []string
	RefMapNew(field string) interface{}
}

type IRefSlice interface {
	IRefField
	RefSliceGet(obj IRefObject, field string, index int) (val interface{}, isNil bool)
	RefSliceSet(obj IRefObject, field string, index int, val interface{})
	RefSliceNew(field string, len int, cap int) interface{}
	RefSliceLength(obj IRefObject, field string) int
}

func init() {
	list := []IRefType{
		&ClassDeclRef{},
		&InterfaceDeclRef{},
		&FieldRef{},
		&EnumDeclRef{},
		&AnyTypeRef{},
		&BasicTypeRef{},
		&ClassTypeRef{},
		&EnumTypeRef{},
		&MapTypeRef{},
		&ArrayTypeRef{},
		&FuncTypeRef{},
	}

	for _, val := range list {
		AddType(val)
	}
	return
}
